package com.tzx.fluttermixedapplication.net.api

import android.util.Log
import com.tzx.fluttermixedapplication.beans.ResultOneDayEnglishData
import com.tzx.fluttermixedapplication.net.RepositoryFactory

object OioApiServiceImpl : IApiService {
    private val iOioApiService = RepositoryFactory.OIO.createApiService(OioApiService::class.java)

    suspend fun getOneDayEnglish(): Result<ResultOneDayEnglishData> = runNetWorkAction {
       resultIntercept(iOioApiService.getOneDayEnglish())
    }

    private fun resultIntercept(result: ResultOneDayEnglishData):ResultOneDayEnglishData {
        Log.d("tanzhenxing", "resultIntercept:${result}")
        if (result.code != 200) {
            throw RuntimeException("server return error code~!")
        }
        return result
    }
}